var showError = function(error){
	Titanium.API.error(error);
	var a = Titanium.UI.createAlertDialog({title:'Error'});
	a.setMessage('Unexpected error: ' + error.code);
	a.show();
};

/*var photo = Ti.UI.createImageView({
	top:10,
	left:10
	width:80,
	height:80,
	borderColor: '#fff',
	borderRadius: 0.3,
	borderWidth: 3
});*/

var firstNameLabel = Titanium.UI.createLabel({
	text:"Firstname",
	textAlign:'center',
	width:'auto',
	height:'auto',
	top:100,
	left:10
});

var firstName = Titanium.UI.createTextField({
	width:'90',
	height:'auto',
	top:150,
	left:10
});

var lastNameLabel = Titanium.UI.createLabel({
	text:"Lastname",
	textAlign:'center',
	width:'auto',
	height:'auto',
  	top:200,
	left:10
});

var lastName = Titanium.UI.createTextField({
	textAlign:'center',
	width:'90',
	height:'auto',
	top:250,
	left:10
});

var addButton = Titanium.UI.createButton({
    title: 'Add',
	width:'90',
	height:'auto',
	top:300,
	left:10
});

addButton.addEventListener('click',function(e){

	Titanium.Media.showCamera({
	success: function(event)
	{
		Ti.API.debug('Our type was: '+event.mediaType);
		/*if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO)
		{
			photo.image:event.media;
		}
		else
		{
			alert("got the wrong type back ="+event.mediaType);
		}*/
	},
	cancel: function(){},
	error: showError,
	saveToPhotoGallery:false,
	allowEditing:false,
	mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO]
	});
});

var viewPersonn = Titanium.UI.createView({
});
//viewPersonn.add(photo);
viewPersonn.add(firstNameLabel);
viewPersonn.add(firstName);
viewPersonn.add(lastNameLabel);
viewPersonn.add(lastName);
viewPersonn.add(addButton);

var data = [{title:"Row 1",hasDetail:true},{title:"Row 2",hasDetail:true}];
var tableview = Titanium.UI.createTableView({data:data});

var bAdd = Titanium.UI.createButton({title:'Add'});
bAdd.addEventListener('click', function(e) {
	
});

var window = Titanium.UI.createWindow();
window.add(viewPersonn);
window.open({fullscreen:true});